package com.chzc.fm.duotin.utils;

/**
 * Created by BillSinla on 2016/6/24.
 */

public class Unicode2CN {

    /**
     * json转码
     */

    /**
     *
     * @param dataStr
     * @return String
     */

    public static String unicode2GBK(String dataStr) {
        int index = 0;
        StringBuffer buffer = new StringBuffer();

        int li_len = dataStr.length();
        while (index < li_len) {
            if (index >= li_len - 1
                    || !"\\u".equals(dataStr.substring(index, index + 2))) {
                buffer.append(dataStr.charAt(index));

                index++;
                continue;
            }

            String charStr = "";
            charStr = dataStr.substring(index + 2, index + 6);

            char letter = (char) Integer.parseInt(charStr, 16);

            buffer.append(letter);
            index += 6;
        }

        return buffer.toString();
    }


}

